<!--
 * @Description: 机会管理
 * @Author: wangwangwang
 * @Date: 2020-08-17 15:52:16
 * @LastEditors: wangwangwang
 * @LastEditTime: 2021-08-12 15:59:02
-->
<template>
  <div class="pages_content table">
    <el-container>
      <el-header>
        <breaDcrumb />
      </el-header>
      <el-main>
        <div class="header_right" @click="showCardNav = !showCardNav">
          <div class="title">搜索</div>
          <div>
            <div :class="{ 'arrowTransform': !showCardNav, 'arrowTransformReturn': showCardNav}">
              <i style="margin-right: 5px" class="el-icon-arrow-down"></i>
            </div>
          </div>
        </div>
        <div v-show="showCardNav" class="hr"></div>
        <el-collapse-transition>
          <div v-show="showCardNav">
            <div class="search">
              <span style="display: inline-block;margin-bottom: 10px;">
                <span style="margin-right: 12px;">工程名称</span>
                <el-input v-model="tableParam.name" style="width: 200px;" clearable placeholder="请输入" @keyup.enter.native="gettableData()" />
              </span>
              <span style="margin-left: 24px;">
                <span style="margin-right: 12px;">状态</span>
                <el-select v-model="tableParam.salesLeadsStatus" placeholder="请选择">
                  <el-option v-for="(item, index) in salesLeadsStatusList" :key="index" :label="item.name" :value="item.id"></el-option>
                </el-select>
              </span>
              <el-button icon="el-icon-search" size="medium" class="bottom_all but1" @click="(tableParam.page = 1), gettableData()">查 询</el-button>
              <el-button size="medium" class="bottom_all_two" style="margin-left:12px;" @click="init()">重 置</el-button>
              <el-button size="medium" class="bottom_all_two" style="margin-left: 12px" @click="tableParamType = true">高级搜索</el-button>
            </div>
          </div>
        </el-collapse-transition>
        <div class="hr"></div>
        <div class="card" style="padding-top: 10px;">
          <div class="card_nav">
            <div>
              <el-button v-if="ButtonList.findIndex(res=>(res.buttonValue=='TIANJIA'))!==-1" size="small" class="bottom_all" style="margin-left: 0;" @click="handleAdd()">
                <i class="icon iconfont iconicon_button_add" style="font-size: 12px;"></i>
                添加
              </el-button>
            </div>
          </div>
          <div v-loading="tableLoading" class="card_info" :style="style">
            <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width:100%" :data="tableData" tooltip-effect="dark">
              <el-table-column align="center" label="工程名称" min-width="140">
                <template slot-scope="scope">
                  <span class="top_link" @click="datails(scope.row)">{{ scope.row.name }}</span>
                </template>
              </el-table-column>
              <el-table-column align="center" label="地理位置" prop="place" min-width="280"></el-table-column>
              <el-table-column align="center" label="提交人" prop="createUserName" min-width="120"></el-table-column>
              <el-table-column align="center" label="提交人电话" prop="createUserPhone" min-width="140"></el-table-column>
              <el-table-column align="center" label="提交时间" prop="createTime" min-width="150"></el-table-column>
              <el-table-column align="center" label="图片" prop="roadworkPhone">
                <template slot-scope="scope">
                  <span v-if="!scope.row.imgs" style="color: #808080;">未提供</span>
                  <span v-if="scope.row.imgs" class="top_link" @click="(datailsData = scope.row), showimgs()">查看</span>
                </template>
              </el-table-column>
              <el-table-column align="center" label="负责人" prop="salesman" min-width="140"></el-table-column>
              <el-table-column align="center" label="状态" prop>
                <template slot-scope="scope">
                  <span>{{ salesLeadsStatusList | fromatTable(scope.row.salesLeadsStatus, 'name', 'id') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="left" width="260" fixed="right">
                <template slot-scope="scope">
                  <el-button size="mini" class="bottom_one" @click="changesaleProgress(scope.row)">跟进记录</el-button>
                  <el-button v-if="(scope.row.salesLeadsStatus == 2||scope.row.salesLeadsStatus == 3)&&ButtonList.some(res=>(res.buttonValue=='JHCB'))" size="mini" class="bottom_one" @click="handleUrged(scope.row)">催办</el-button>
                  <el-button v-if="scope.row.salesLeadsStatus == 1&&ButtonList.some(res=>(res.buttonValue=='JHHN'))" size="mini" class="bottom_one" @click="ignoreSubmit(scope.row)">忽略</el-button>
                  <el-button v-if="scope.row.salesLeadsStatus == 1&&ButtonList.some(res=>(res.buttonValue=='JHFP'))" size="mini" class="bottom_one" @click="shareHandle(scope.row, 2)">分派</el-button>
                  <el-button v-if="(scope.row.salesLeadsStatus == 2 || scope.row.salesLeadsStatus == 3|| scope.row.salesLeadsStatus == 4)&&ButtonList.some(res=>(res.buttonValue=='JHZP'))" size="mini" class="bottom_one" @click="shareHandle(scope.row, 3)">转派</el-button>
                  <el-button v-if="scope.row.salesLeadsStatus == 5&&ButtonList.some(res=>(res.buttonValue=='JHCKSQ'))" size="mini" class="bottom_one" @click="handleApply(scope.row)">查看申请</el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </el-main>
      <div class="card_bottom">
        <div class="card_bottom_left">
          <div class="top_page_totle">总共{{ total }}条</div>
          <el-pagination :current-page.sync="tableParam.page" :page-size="tableParam.pageSize" :page-sizes="[10, 20, 30, 40,50,100,200,500,1000]" layout="prev,pager,sizes,next,jumper" :total="total" @size-change="sizeChange" @current-change="gettableData()"></el-pagination>
        </div>
        <div>
          <el-button size="mini" icon="el-icon-refresh-right" class="bottom_all_two" @click="gettableData">刷新</el-button>
        </div>
      </div>
    </el-container>
    <!-- 忽略 -->
    <el-dialog v-dialogDrag :visible.sync="ignoreVisible" width="580px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">填写原因</span>
      <div class="dialoginfo">
        <el-form ref="refreasonForm" :model="reasonForm" label-width="80px">
          <el-form-item prop="ignoreReasonId" :rules="[{required: true,message: '请选择忽略原因',trigger: 'change',}]">
            <span slot="label">忽略原因</span>
            <el-select v-model="reasonForm.ignoreReasonId" placeholder="请选择" style="width:380px;">
              <el-option label="已介入供应" :value="1"></el-option>
              <el-option label="未中标" :value="2"></el-option>
              <el-option label="主动放弃" :value="3"></el-option>
              <el-option label="信息无效" :value="4"></el-option>
              <el-option label="其他原因" :value="5"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="备注">
            <el-input v-model="reasonForm.ignoreReason" rows="5" resize="none" type="textarea" style="width:380px;"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="ignoreVisible = false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px;" @click="searchSubmit()">提 交</el-button>
      </span>
    </el-dialog>
    <!-- 查看详情 -->
    <el-dialog v-dialogDrag :visible.sync="datailsDialog" width="580px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">工程信息</span>
      <div class="dialoginfo">
        <el-form :inline="true" label-width="90px">
          <el-form-item label="工程名称  :">
            <div style="width: 150px;">{{ datailsData.name }}</div>
          </el-form-item>
          <el-form-item label="地理位置  :">
            <div style="width: 150px;">{{ datailsData.place }}</div>
          </el-form-item>
          <el-form-item label="工程性质  :">
            <div style="width: 150px;">{{ datailsData.type }}</div>
          </el-form-item>
          <el-form-item label="施工单位  :">
            <div style="width: 150px;">{{ datailsData.roadwork }}</div>
          </el-form-item>
          <el-form-item label="工程联系人  :">
            <div style="width: 150px;">{{ datailsData.roadworklInkman }}</div>
          </el-form-item>
          <el-form-item label="联系电话  :">
            <div style="width: 150px;">{{ datailsData.roadworkPhone }}</div>
          </el-form-item>
          <el-form-item label="工程提交人  :">
            <div style="width: 150px;">{{ datailsData.createUserName }}</div>
          </el-form-item>
          <el-form-item label="提交电话  :">
            <div style="width: 150px;">{{ datailsData.createUserPhone }}</div>
          </el-form-item>
          <el-form-item label="提交时间  :">
            <div style="width: 150px;">{{ datailsData.createTime }}</div>
          </el-form-item>
          <el-form-item label="现场情况:">
            <div style="width: 150px;">{{ datailsData.currentSituation }}</div>
          </el-form-item>
          <el-form-item label="图片信息  :">
            <span v-if="!datailsData.imgs" style="color: #808080;">未提供</span>
            <span v-if="datailsData.imgs" class="top_link" @click="showimgs()">查看</span>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="datailsDialog = false">关 闭</el-button>
      </span>
    </el-dialog>
    <!-- 查看图片 -->
    <el-dialog v-dialogDrag :visible.sync="imgsDialog" width="980px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">图片信息</span>
      <div class="dialoginfo">
        <div style="display:flex;">
          <span v-for="(item, index) in srcList" :key="index" style="display: inline-block;">
            <el-image v-if="$options.filters.imgMp4TypeFun(item) == 'img'" style="width: 200px; height:200px;margin:0 10px 10px 10px;border-radius: 4px;" :src="item" :preview-src-list="srcList" :z-index="10000"></el-image>
            <video v-else width="200" height="200" style="width: 200px; height:200px;margin:0 10px 10px 10px;border-radius: 4px;" :src="item" controls>
              您的浏览器不支持 HTML5 video 标签。
            </video>
          </span>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="imgsDialog = false">关 闭</el-button>
      </span>
    </el-dialog>
    <!-- 选择人员 -->
    <el-dialog v-dialogDrag :visible.sync="personVisible" width="600px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">选择人员</span>
      <div class="dialoginfo">
        <el-form ref="fromDate1" :model="fromDate" label-width="80px">
          <el-form-item prop="businessRegistration" :rules="[{required: true,message: '请选择经营等级',trigger: 'change',}]" label-width="250px">
            <span slot="label">经营等级（该机会信息的重要程度）</span>
            <el-rate v-model="fromDate.businessRegistration" :colors="colors" style="margin-top:7px;">
            </el-rate>
          </el-form-item>
          <el-form-item prop="salesmanId" :rules="[{required: true,message: '请选择负责人',trigger: 'change',}]">
            <span slot="label">负责人</span>
            <el-select key="fromDate.salesmanId" ref="salesman" v-model="fromDate.salesmanId" filterable @change="$nextTick(()=>{fromDate.salesman = $refs.salesman.selectedLabel})">
              <el-option v-for="(item,k) in principalarr" :key="k" :label="item.name" :value="item.id"></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="分派备注">
            <el-input v-model="fromDate.dispatchRemark" style="width:420px;" type="textarea"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="personVisible = false">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px;" @click="getPerson()">提 交</el-button>
      </span>
    </el-dialog>
    <!-- 高级搜索 -->
    <el-dialog v-dialogDrag :visible.sync="tableParamType" width="650px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">高级搜索</span>
      <div class="dialoginfo">
        <el-form ref="reftableParam" :inline="true" :model="tableParam" label-width="110px">
          <el-form-item prop="code">
            <span slot="label">提交人</span>
            <el-input v-model="tableParam.createUserName" tplaceholder="请输入" clearable style="width:400px;"></el-input>
          </el-form-item>
          <el-form-item prop="code">
            <span slot="label">提交时间</span>
            <el-date-picker v-model="startTimDateEndTimDate" type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" unlink-panels start-placeholder="开始时间" end-placeholder="结束时间" @change="tableParam.startDateTime=startTimDateEndTimDate[0]||'',tableParam.endDateTime=startTimDateEndTimDate[1]||''"></el-date-picker>
          </el-form-item>
          <el-form-item prop="code">
            <span slot="label">销售员</span>
            <el-input v-model="tableParam.salesman" tplaceholder="请输入" clearable style="width:400px;"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="tableParamType=false,tableParam.createUserName='',startTimDateEndTimDate=[],tableParam.startDateTime='',tableParam.endDateTime='',tableParam.salesman=''">取 消</el-button>
        <el-button class="bottom_all" style="margin-left: 24px" @click="gettableData(),tableParamType=false">搜 索</el-button>
      </span>
    </el-dialog>
    <!-- 跟进记录 -->
    <el-dialog v-dialogDrag :visible.sync="saleProgressDialog" width="980px" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">{{ itemdata.name }}（{{ itemdata.roadwork }}）</span>
      <div class="saledialoginfo">
        <div :class="itemdata.salesLeadsStatus>5?'styleA':'styleB'">
          <el-timeline>
            <template v-for="(item, index) in saleProgressData">
              <el-timeline-item :key="index" :timestamp="new Date(item.createTime).Format('yyyy-MM-dd')" placement="top">
                <el-card>
                  <p>{{ item.content }}</p>
                  <div style="text-align: right;">更新人：{{ item.userName }}</div>
                </el-card>
              </el-timeline-item>
            </template>
            <div v-show="saleProgressData.length==0" style="text-align:center;">
              暂无记录
            </div>
          </el-timeline>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="saleProgressDialog = false">关 闭</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="addVisible" width="60%" :close-on-click-modal="false">
      <span slot="title" class="dialog-title">{{readyOnly?'查看机会':'添加机会'}}</span>
      <el-form ref="addForm" :disabled='readyOnly' :rules="rules" :inline="true" :model="addForm" label-width="110px">
        <el-form-item prop="chanceTypeId">
          <span slot="label" style="color:#FF0000;">机会类型</span>
          <el-select ref="chanceTypeId" v-model="addForm.chanceTypeId" placeholder="请选择" @change="$nextTick(()=>{addForm.chanceType = $refs.chanceTypeId.selectedLabel})">
            <el-option v-for="(item, index) in clientTypeIdList" :key="index" :label="item.itemName" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="typeId">
          <span slot="label" style="color:#FF0000;">项目类别</span>
          <el-select ref="typeId" v-model="addForm.typeId" placeholder="请选择" @change="$nextTick(()=>{addForm.type = $refs.typeId.selectedLabel})">
            <el-option v-for="(item, index) in typeIdList" :key="index" :label="item.itemName" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="name">
          <span slot="label" style="color:#FF0000;">工程名称</span>
          <el-input v-model="addForm.name" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <el-form-item prop="administrativeDistricts0">
          <span slot="label">行政区县</span>
          <el-cascader v-model="addForm.administrativeDistricts0" style="width:227px;" :options="treeData" filterable @change="administrativeDistrictsFun()"></el-cascader>
        </el-form-item>
        <el-form-item prop="place">
          <span slot="label" style="color:#FF0000;">地理位置</span>
          <el-input v-model="addForm.place" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <el-form-item prop="rateOfProgressId">
          <span slot="label">项目进度</span>
          <el-select ref="rateOfProgressId" v-model="addForm.rateOfProgressId" placeholder="请选择" @change="$nextTick(()=>{addForm.rateOfProgress = $refs.rateOfProgressId.selectedLabel})">
            <el-option v-for="(item, index) in rateOfProgressIdList" :key="index" :label="item.itemName" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <div>预估合同量（m<sup>3</sup>/M）</div>
        <el-form-item prop="expectedAmount">
          <span slot="label" style="color:#FF0000;">预拌</span>
          <el-input v-model="addForm.expectedAmount" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <el-form-item prop="tubularColumn">
          <span slot="label" style="color:#FF0000;">管柱</span>
          <el-input v-model="addForm.tubularColumn" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <el-form-item prop="fabricated">
          <span slot="label" style="color:#FF0000;">装配式</span>
          <el-input v-model="addForm.fabricated" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <div>业主</div>
        <el-form-item prop="ownerName">
          <span slot="label">名称</span>
          <el-input v-model="addForm.ownerName" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <el-form-item prop="ownerContacts">
          <span slot="label">联系人</span>
          <el-input v-model="addForm.ownerContacts" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <el-form-item prop="ownerPhone">
          <span slot="label">联系电话</span>
          <el-input v-model="addForm.ownerPhone" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <div>施工总承包</div>
        <el-form-item prop="constructionName">
          <span slot="label" style="color:#FF0000;">名称</span>
          <el-input v-model="addForm.constructionName" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <el-form-item prop="constructionContacts">
          <span slot="label" style="color:#FF0000;">联系人</span>
          <el-input v-model="addForm.constructionContacts" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <el-form-item prop="constructionPhone">
          <span slot="label" style="color:#FF0000;">联系电话</span>
          <el-input v-model="addForm.constructionPhone" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <el-form-item prop="contractUnitId">
          <span slot="label">合同单位</span>
          <el-select v-model="addForm.contractUnitId" placeholder="请选择" filterable clearable>
            <el-option v-for="(item, index) in roadworkIdList" :key="index" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="startTime">
          <span slot="label" style="color:#FF0000;">起供时间</span>
          <el-date-picker v-model="addForm.startTime" type="datetime" placeholder="选择日期时间" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
        </el-form-item>
        <!-- <div>成交情况</div>
        <el-form-item prop="winningBidders">
          <span slot="label">中标方</span>
          <el-input v-model="addForm.winningBidders" tplaceholder="请输入" clearable></el-input>
        </el-form-item>
        <el-form-item prop="dealPrice">
          <span slot="label">成交价格</span>
          <el-input v-model="addForm.dealPrice" tplaceholder="请输入" clearable></el-input>
        </el-form-item> -->
        <el-form-item>
          <span slot="label">照片/视频</span>
          <el-upload
            ref="upload"
            action="/resource/resources/upload"
            list-type="picture-card"
            :disabled="readyOnly"
            :on-success="handleSuccess"
            :on-remove="handleRemove">
            <i class="el-icon-plus"></i>
          </el-upload>
        </el-form-item>
        <div v-if="readyOnly">
          <el-form-item prop="createUserName">
            <span slot="label">信息提交人</span>
            <el-input v-model="addForm.createUserName" tplaceholder="请输入" clearable></el-input>
          </el-form-item>
          <el-form-item prop="createUserPhone">
            <span slot="label">提交人电话</span>
            <el-input v-model="addForm.createUserPhone" tplaceholder="请输入" clearable></el-input>
          </el-form-item>
          <el-form-item prop="createTime">
            <span slot="label">提交时间</span>
            <el-input v-model="addForm.createTime" tplaceholder="请输入" clearable></el-input>
          </el-form-item>
          <el-form-item prop="currentSituation">
            <span slot="label">现场情况</span>
            <el-input v-model="addForm.currentSituation" tplaceholder="请输入" clearable></el-input>
          </el-form-item>
        </div>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" style="margin-left: 24px;" @click="addVisible = false">关 闭</el-button>
        <el-button v-if="!readyOnly" class="bottom_all" @click="handleSure">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import mixin from "@/mixins/ICPSmixin.js";
import {
  queryPageB,
  getsaleProgress,
  assignOrRedeploy,
  ignore,
  press_to_do,
  salesLeadssave,
  queryAllByCompanyId,
} from "@/api/internetSales/chanceManagement.js";
import { getDicType } from "@/api/common";
import { get_simple_user_listBycompanyId } from '@/api/GHnumber/contract'
import { getUserInfo } from "@/utils/auth.js";
import treeData from '@/views/platform/ICPS/basicConfig/address.js';
export default {
  mixins: [mixin],
  data() {
    return {
      treeData,
      colors: ['#99A9BF', '#F7BA2A', '#FF9900'],
      startTimDateEndTimDate: [],
      tableParamType: false,
      UserInfo: '',
      fromDate: { businessRegistration: 5, dispatchRemark: '', salesmanId: '' },
      principalarr: [],
      principalName: "",
      /*表格增删改查及下载接口*/
      queryPage: queryPageB,
      pagesType: 0,
      rules: {
        chanceTypeId: [{ required: true, message: "请选择机会类型", trigger: "change" }],
        typeId: [{ required: true, message: "请选择项目类别", trigger: "change" }],
        name: [{ required: true, message: "请输入工程名称", trigger: "change" }],
        place: [{ required: true, message: "请输入地理职位", trigger: "change" }],
        startTime: [{ required: true, message: "请输入起供时间", trigger: "change" }],
        expectedAmount: [{ required: true, message: "请输入预拌", trigger: "change" }],
        tubularColumn: [{ required: true, message: "请输入管柱", trigger: "change" }],
        fabricated: [{ required: true, message: "请输入装配式", trigger: "change" }],
        constructionName: [{ required: true, message: "请输入名称", trigger: "change" }],
        constructionContacts: [{ required: true, message: "请输入联系人", trigger: "change" }],
        constructionPhone: [{ required: true, message: "请输入联系电话", trigger: "change" }],
      },
      reasonForm: {
        id: "",
        remark: "",
      },
      ignoreVisible: false,
      ignoreids: [],
      salesLeadsStatusList: [
        { name: "未处理", id: 1 },
        { name: "已分派", id: 2 },
        { name: "已转派", id: 3 },
        { name: "跟进中", id: 4 },
        { name: "申请停止跟进", id: 5 },
        { name: "已停止", id: 6 },
        { name: "已忽略", id: 7 },
        { name: "已登记", id: 8 },
      ],
      datailsDialog: false,
      datailsData: {},
      imgsDialog: false,
      srcList: [],
      saleProgressDialog: false,
      itemdata: {},
      disabled: true,
      saleProgressData: [],
      saleProgresscontent: "",
      personVisible: false,
      itemDats: {},
      addVisible: false,
      addForm: {},
      typeIdList: [],
      clientTypeIdList: [],
      rateOfProgressIdList: [],
      roadworkIdList: [],
      fileList: '',
      readyOnly: false,
    };
  },
  async created() {
    this.UserInfo = getUserInfo();
    this.tableParam = { ...this.tableParam, name: "", salesLeadsStatus: "", status: 2, createUserName: '', startDateTime: '', endDateTime: '', salesman: '' };
    this.init();
    getDicType({ code: "EngineeringNature" }).then((res) => {
      this.typeIdList = res.data.items;
    });
    getDicType({ code: "customerType" }).then((res) => {
      this.clientTypeIdList = res.data.items;
    });
    getDicType({ code: "ProjectProgress" }).then((res) => {
      this.rateOfProgressIdList = res.data.items;
    });
    queryAllByCompanyId().then((res) => {
      this.roadworkIdList = res.data
    });
    this.treeData.forEach((v) => {
      v.children.forEach((res) => {
        res.children.forEach((res2) => {
          delete res2.children
        })
      })
    })
  },
  watch: {
    saleProgresscontent() {
      if (this.saleProgresscontent == "") {
        this.disabled = true;
      } else {
        this.disabled = false;
      }
    },
  },
  methods: {
    handleSuccess (res, file, fileList) {
      this.fileList = fileList.map(item => item.response.data.fileUrl).join(',')
    },
    handleRemove (res, fileList) {
      this.fileList = fileList.map(item => item.response.data.fileUrl).join(',')
    },
    administrativeDistrictsFun() {
      this.addForm.administrativeDistricts = JSON.stringify(this.addForm.administrativeDistricts0)
      this.$forceUpdate()
    },
    handleAdd () {
      this.fileList = '';
      if (this.$refs.addForm) {
        this.$refs.upload.clearFiles();
        this.$refs.addForm.resetFields();
      }
      this.addVisible = true;
      this.readyOnly = false;
    },
    handleSure () {
      this.$refs.addForm.validate((valid) => {
        if (valid) {
          const params = {
            ...this.addForm,
            incidental: {
              ownerName: this.addForm.ownerName,
              ownerContacts: this.addForm.ownerContacts,
              ownerPhone: this.addForm.ownerPhone,
              constructionName: this.addForm.constructionName,
              constructionContacts: this.addForm.constructionContacts,
              constructionPhone: this.addForm.constructionPhone,
            },
            imgs: this.fileList,
            dataSources: 1,
          }
          salesLeadssave(params).then(res => {
            if (res.code === 1001) {
              this.$message.success('添加成功');
              this.addVisible = false;
              this.gettableData();
            }
          })
        }
      });
    },
    changeVisited(data, status) {
      this.visited = status;
      this.visitedata = data;
    },
    close() {
      this.visitedata = "";
      this.visited = false;
    },

    pass(low, status) {
      let _this = this;
      _this
        .$confirm(
          `此操作将${status == 6 ? "同意" : "拒绝"}停止跟进此信息, 是否继续?`,
          "提示",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            cancelButtonClass: "bottom_all_two",
            confirmButtonClass: "bottom_all",
            type: "warning",
          }
        )
        .then(() => {
          let data = new Object();
          data.id = low.id;
          data.salesLeadsStatus = status;
          assignOrRedeploy(data).then(() => {
            _this.gettableData();
          });
        })
        .catch(() => { });
    },
    /**
     * @Description: 催办
     * @Param: 
     * @Author: wangwangwang
     * @param {*} data
     */
    handleUrged(data) {
      press_to_do({ salesman: data.salesman, salesmanId: data.salesmanId, name: data.name }).then((res) => {
        if (res.code == 1001) {
          this.$message({
            message: '催办成功！',
            type: 'success'
          });
          this.gettableData()
        }
      })
    },
    /**
     * @Description: 查看停止申请
     * @Param: 
     * @Author: wangwangwang
     */
    handleApply(data) {
      const self = this;
      this.$confirm(data.stopReason, '申请停止', {
        distinguishCancelAndClose: true,
        confirmButtonText: '同意',
        cancelButtonClass: 'bottom_all_two',
        confirmButtonClass: 'bottom_all',
        cancelButtonText: '否决',
        type: 'warning'
      }).then(() => {
        const params = {
          id: data.id,
          salesLeadsStatus: 6,
        }
        assignOrRedeploy(params).then(() => {
          self.gettableData();
        });
      }).catch((action) => {
        if (action === 'cancel') {
          const params = {
            id: data.id,
            salesLeadsStatus: 4,
          }
          assignOrRedeploy(params).then(() => {
            self.gettableData();
          });
        }
      });
    },
    changesaleProgress(data) {
      getsaleProgress({ enginnerId: data.id }).then((res) => {
        this.saleProgressData = res.data;
        this.itemdata = data;
        this.saleProgressDialog = true;
      });
    },
    showimgs() {
      this.srcList = this.datailsData.imgs.split(",");
      this.srcList = this.srcList.map(res => '/file/' + res);
      console.log(this.srcList)
      this.imgsDialog = true;
    },
    datails(data) {
      this.addForm = data;
      if (this.addForm.administrativeDistricts) {
        this.addForm.administrativeDistricts0 = JSON.parse(this.addForm.administrativeDistricts)
      }
      this.addForm.ownerName = this.addForm.incidental.ownerName,
      this.addForm.ownerContacts = this.addForm.incidental.ownerContacts,
      this.addForm.ownerPhone = this.addForm.incidental.ownerPhone,
      this.addForm.constructionName = this.addForm.incidental.constructionName,
      this.addForm.constructionContacts = this.addForm.incidental.constructionContacts,
      this.addForm.constructionPhone = this.addForm.incidental.constructionPhone,
      this.addVisible = true;
      this.readyOnly = true;
    },
    init() {
      /*重置数据*/
      this.tableParam.name = "";
      this.tableParam.salesLeadsStatus = "";
      this.gettableData();
    },
    ignoreSubmit(data) {
      this.reasonForm.id = data.id;
      this.ignoreVisible = true;
    },
    /*转派，转派*/
    shareHandle(data, status) {
      this.fromDate.id = data.id
      this.fromDate.salesLeadsStatus = status
      this.fromDate.businessRegistration = data.businessRegistration || 5
      this.fromDate.salesmanId = data.salesmanId
      this.fromDate.dispatchRemark = data.dispatchRemark
      this.principalName = data.salesman
      this.personVisible = true;
      const params = {
        roleId: '12b2f6ff304148fd89141e9faa9afb96',
        orgznizationId: data.companyId,
      }
      this.principalarr = []
      get_simple_user_listBycompanyId(params).then(res => {
        if (res.code === 1001) {
          this.principalarr = res.data;
        }
      })
    },
    getPerson() {
      this.$refs.fromDate1.validate((valid) => {
        if (valid) {
          assignOrRedeploy(this.fromDate).then(() => {
            this.$message({
              message: "操作成功",
              type: "success",
            });
            this.gettableData();
            this.personVisible = false;
          });
        } else {
          return false;
        }
      });

    },
    searchSubmit() {
      this.$refs.refreasonForm.validate((valid) => {
        if (valid) {
          const params = {
            ignoreReason: ['', '已介入供应', '未中标', '主动放弃', '信息无效', '其他原因'][this.reasonForm.ignoreReasonId * 1],
            ignoreReasonId: this.reasonForm.ignoreReasonId,
            remark: this.reasonForm.ignoreReason,
            id: this.reasonForm.id
          }
          ignore(params).then((res) => {
            if (res.code == 1001) {

              this.$message({
                message: "忽略成功",
                type: "success",
              });
              this.gettableData();
              this.ignoreVisible = false;
              this.$refs.refreasonForm.resetFields();
            }
          });
        } else {
          return false;
        }
      });
    },
    sizeChange(value) {
      this.tableParam.pageSize = value;
      this.gettableData();
    },
  },
  filters: {
    imgMp4TypeFun(d) {
      if (d.includes("jpeg") || d.includes("jpg") || d.includes("png")) {
        return "img";
      } else {
        return "mp4";
      }
    },
  }
};
</script>

<style lang="scss" scoped>
.saledialoginfo {
  padding: 20px 20px 0 0px;
  max-height: calc(85vh - 220px);
}
.el-input,
.el-select {
  width: 240px;
}
.top_link {
  color: #008000;
}
.top_link:hover {
  cursor: pointer;
  opacity: 0.7;
}
.table_link {
  margin-left: 10px;
  color: $bg_color;
}

.table_link:hover {
  opacity: 0.8;
}
.tabtop {
  width: 378px;
  display: flex;
  border: $bg_color 1px solid;
  border-radius: 4px;
  margin: 20px 20px 0 20px;
  > div {
    height: 40px;
    width: 190px;
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    .text {
      width: 188px;
      @include discen;
      line-height: 40px;
      color: $bg_color;
    }
    .active {
      width: 188px;
      @include discen;
      line-height: 40px;
      color: #ffffff;
      background: $bg_color;
      border-radius: 4px;
    }
    .hr {
      height: 20px;
      width: 2px;
      background: $bg_color;
    }
  }
}
</style>
